package com.example.yy.widgettest_318yy;

import android.content.Intent;

import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.ImageButton;
import android.widget.ImageView;
import android.widget.TextView;

import java.util.IdentityHashMap;
import java.util.StringTokenizer;

public class MainActivity extends AppCompatActivity implements View.OnClickListener{

    private TextView tv;
    private EditText et;
    private Button btt,bti;
    private ImageView iv;
    private ImageButton ivb;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        init();
    }

    private void init() {
        tv=(TextView)findViewById(R.id.textView4);
        et=(EditText)findViewById(R.id.editText3);
        btt=(Button)findViewById(R.id.button3);
        bti=(Button)findViewById(R.id.button4);
        ivb=(ImageButton)findViewById(R.id.imageButton);
        iv=(ImageView)findViewById(R.id.imageView);

        btt.setOnClickListener(this);
        bti.setOnClickListener(this);
        ivb.setOnClickListener(this);
    }

    @Override
    public void onClick(View v) {
        switch (v.getId()){
            case R.id.button3:
                String str=et.getText().toString();
                tv.setText(str);
                break;
            case R.id.button4:
                //iv.setImageResource(R.drawable);
                break;
            case R.id.imageButton:
                Intent intent=new Intent(MainActivity.this,NewActivity.class);
                intent.putExtra("param1",et.getText().toString());
                intent.putExtra("param2",3);
                startActivity(intent);
                //break;
        }
    }
}
